layui.define(['form', 'admin'], function (exports) { // 也可以依赖其他模块\
    let n = layui.admin, t = n.tabsPage, r = layui.$;
    let form = layui.form
    const formLoad = {
        render: function (obj) {
            form.set({
                autocomplete: 'off' // 阻止 input 框默认的自动输入完成功能
            })
            form.on('submit(save)',
                function (data) {
                    if (obj) {
                        obj(data.field)
                    } else {
                       save(data.field)
                    }
                    return false;
                });
        }, openTab: function (a, d) {
            let p = r(parent.document);
            let l, u = p.find("#LAY_app_tabsheader>li")
            u.each(function (e) {
                let i = r(this), n = i.attr("lay-id");
                if (n === a && !l) {
                    l = n
                }
            });
            let pid = ""
            if (!l) {
                let app_body = p.find("#LAY_app_body")
                pid = app_body.find(".layui-show>iframe").attr("id")
                app_body.find('.layui-show').removeClass("layui-show");
                app_body.append(['<div class="layadmin-tabsbody-item layui-show">', '<iframe src="' + __basePath + a + '" frameborder="0" class="layadmin-iframe"  scrolling="auto" name="' + a + '" id="' + a + '" pid="' + pid + '" tab="tab"></iframe>', "</div>"].join(""))
                window.parent.layui.element.tabAdd(o, {title: "<span>" + d + "</span>", id: a, attr: pid});
            }
            t.index = u.length;
            window.parent.layui.element.tabChange(o, a);
            n.tabsBodyChange(t.index, {url: a, text: d, attr: pid})
        }, openIframe: function (url, title, area) {
            layer.open({
                type: 2, title: title, shadeClose: true, maxmin: true, //开启最大化最小化按钮
                area: area, content: [__basePath + url, 'yes']
            });
        }
    }
    exports("edit", formLoad)
});